package com.mvu.banana.internal;

import com.mvu.banana.domain.server.EMF;
import com.mvu.banana.domain.server.ServerProperties;
import com.mvu.banana.internal.server.CredentialBuilder;
import org.apache.log4j.Logger;

import javax.persistence.EntityManagerFactory;

/**
 * Class description...
 *
 * @author mvu
 */
public class DropDB {
  private static final Logger logger = Logger.getLogger(DropDB.class);

  static {
    ServerProperties.get().setProperty("hibernate.hbm2ddl.auto", "create");
  }

  public static void main(String[] args) {
    logger.info("Drop database...");
    EntityManagerFactory factory = EMF.get();
    factory.createEntityManager();
    loadSampleData();
    factory.close();
    logger.info("Done - Drop database");
  }

  private static void loadSampleData() {
    new CredentialBuilder().withUsername("demo").commit();
  }
}
